#include "motordummy.h"
#include <QDateTime>
#include <QCoreApplication>
MotorDummy::MotorDummy(MotorBase *parent) : MotorBase (parent)
{

}

void MotorDummy::moveAbsolute(const double &a)
{
    Q_UNUSED(a)
}

void MotorDummy::moveRelative(const double &a)
{
    motor_posi_fake += a;
    motor_posi_fake = motor_posi_fake >= 360 ? motor_posi_fake - 360 : motor_posi_fake;
    mySleep(1000);
    emit positionArrived(motor_posi_fake);
}

void MotorDummy::position()
{}

void MotorDummy::motorQuit()
{
    emit motorClosed();
}

void MotorDummy::set_Motor_azAngleStep(const double &s)
{
    Q_UNUSED(s)
}

void MotorDummy::prepare(const SOFTWARESETTINGS mysetting)
{
    motor_posi_fake = mysetting.azAngleStart;
    emit positionArrived(mysetting.azAngleStart);
}

void MotorDummy::motorTest(const SOFTWARESETTINGS mysetting)
{}

void MotorDummy::motorTry(const double tryAngle)
{
    Q_UNUSED(tryAngle)
}

void MotorDummy::mySleep(unsigned int msec)
{
    QTime delayTime = QTime::currentTime().addMSecs(msec);
    while (QTime::currentTime() < delayTime)
        QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
}
